package com.wm.blog_admin.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wm.blog_admin.controller.base.AdminBaseController;
import com.wm.blog_admin.query.TCategoryMenuQuery;
import com.wm.blog_admin.service.TCategoryMenuService;
import com.wm.blog_common.bean.QueryPage;
import com.wm.blog_common.domain.TCategoryMenuDO;
import com.wm.blog_common.entity.TCategoryMenu;
import com.wm.blog_common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 管理员表 前端控制器
 * </p>
 *
 * @author wm_yu
 * @since 2020-03-24
 */
@Slf4j
@RestController
@RequestMapping("/ai/tCategoryMenu")
public class TCategoryMenuController extends AdminBaseController {

    @Autowired
    private TCategoryMenuService tCategoryMenuService;

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result<TCategoryMenuDO> get(@PathVariable Long id) {
        return tCategoryMenuService.selectById(id);
    }

    /**
     * 根据ID删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Result<Boolean> delete(@PathVariable Long id){
        return tCategoryMenuService.deleteById(id);
    }

    /**
     * 添加
     * @param tCategoryMenu
     * @return
     */
    @PostMapping
    public Result insert(@RequestBody TCategoryMenu tCategoryMenu){
        return tCategoryMenuService.insert(tCategoryMenu);
    }

    /**
     * 修改
     * @param tCategoryMenu
     * @return
     */
    @PutMapping
    public Result update(@RequestBody TCategoryMenu tCategoryMenu){
        return tCategoryMenuService.update(tCategoryMenu);
    }

    /**
     * 分页查询
     * @param current   查询页
     * @param size   每页显示条数
     * @param query 查询参数
     * @return
     */
    @GetMapping("/page")
    public Result<Page<TCategoryMenuDO>> page(Integer current, Integer size, TCategoryMenuQuery query){
        return tCategoryMenuService.page(new QueryPage(current,size),query);
    }


}
